<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Config::ConfigFile</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Config::ConfigFile</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/svengali/config_rb.html">
                lib/svengali/config.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000062">append_str</a>&nbsp;&nbsp;
      <a href="#M000060">new</a>&nbsp;&nbsp;
      <a href="#M000064">remove_col_by_regexp</a>&nbsp;&nbsp;
      <a href="#M000063">remove_col_by_str</a>&nbsp;&nbsp;
      <a href="#M000061">replace_col</a>&nbsp;&nbsp;
      <a href="#M000065">save</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="../FileIO.html">FileIO</a></span>
      </div>
    </div>

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000060" class="method-detail">
        <a name="M000060"></a>

        <div class="method-heading">
          <a href="#M000060" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(remote_path_str,sftp_session)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
ssh_session =&gt; Net::SFTP::Session <a
href="ConfigFile.html">ConfigFile</a> class doesn&#8216;t manage passed
sftp_session value
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000060-source">
<pre>
<span class="ruby-comment cmt"># File lib/svengali/config.rb, line 22</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">remote_path_str</span>,<span class="ruby-identifier">sftp_session</span>)
      <span class="ruby-ivar">@sftp_session</span> = <span class="ruby-identifier">sftp_session</span>

      <span class="ruby-ivar">@remote_filepath_str</span> = <span class="ruby-identifier">remote_path_str</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_exist</span>(<span class="ruby-identifier">remote_path_str</span>)
<span class="ruby-comment cmt">#        config_file = @sftp_session.open!(remote_path_str)</span>
        <span class="ruby-ivar">@config_file_contents</span> = <span class="ruby-identifier">get_contents_remote</span>(<span class="ruby-ivar">@remote_filepath_str</span>)
      <span class="ruby-keyword kw">else</span>
        <span class="ruby-ivar">@config_file_contents</span> = <span class="ruby-value str">&quot;&quot;</span>
      <span class="ruby-keyword kw">end</span>

    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000062" class="method-detail">
        <a name="M000062"></a>

        <div class="method-heading">
          <a href="#M000062" class="method-signature">
          <span class="method-name">append_str</span><span class="method-args">(str)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000062-source">
<pre>
<span class="ruby-comment cmt"># File lib/svengali/config.rb, line 48</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">append_str</span>(<span class="ruby-identifier">str</span>)
      <span class="ruby-ivar">@config_file_contents</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">str</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000064" class="method-detail">
        <a name="M000064"></a>

        <div class="method-heading">
          <a href="#M000064" class="method-signature">
          <span class="method-name">remove_col_by_regexp</span><span class="method-args">(regexp)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
remove columns which matched passed regular expression
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000064-source">
<pre>
<span class="ruby-comment cmt"># File lib/svengali/config.rb, line 68</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_col_by_regexp</span>(<span class="ruby-identifier">regexp</span>)
      <span class="ruby-identifier">not_inp</span>()
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000063" class="method-detail">
        <a name="M000063"></a>

        <div class="method-heading">
          <a href="#M000063" class="method-signature">
          <span class="method-name">remove_col_by_str</span><span class="method-args">(str)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
remove all columns which contains passed string
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000063-source">
<pre>
<span class="ruby-comment cmt"># File lib/svengali/config.rb, line 53</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_col_by_str</span>(<span class="ruby-identifier">str</span>)
      <span class="ruby-identifier">orig_contents_io</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@config_file_contents</span>)
      <span class="ruby-identifier">removed_contents_io</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>()
      <span class="ruby-identifier">orig_contents_io</span>.<span class="ruby-identifier">each_line</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">str</span>)
           <span class="ruby-identifier">removed_contents_io</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">line</span>)
         <span class="ruby-keyword kw">end</span>
      }
      <span class="ruby-identifier">orig_contents_io</span>.<span class="ruby-identifier">close</span>()
      <span class="ruby-identifier">removed_contents_io</span>.<span class="ruby-identifier">close</span>()

      <span class="ruby-ivar">@config_file_contents</span> = <span class="ruby-identifier">removed_contents_io</span>.<span class="ruby-identifier">string</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000061" class="method-detail">
        <a name="M000061"></a>

        <div class="method-heading">
          <a href="#M000061" class="method-signature">
          <span class="method-name">replace_col</span><span class="method-args">(original_col_str,replaced_col_str)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
replace columns which has specified content
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000061-source">
<pre>
<span class="ruby-comment cmt"># File lib/svengali/config.rb, line 36</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">replace_col</span>(<span class="ruby-identifier">original_col_str</span>,<span class="ruby-identifier">replaced_col_str</span>)
      <span class="ruby-identifier">orig_contents_io</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@config_file_contents</span>)
      <span class="ruby-identifier">replaced_contents_io</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>()
      <span class="ruby-identifier">orig_contents_io</span>.<span class="ruby-identifier">each_line</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
         <span class="ruby-identifier">replaced_contents_io</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">line</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">original_col_str</span>,<span class="ruby-identifier">replaced_col_str</span>))
      }
      <span class="ruby-identifier">orig_contents_io</span>.<span class="ruby-identifier">close</span>()
      <span class="ruby-identifier">replaced_contents_io</span>.<span class="ruby-identifier">close</span>()

      <span class="ruby-ivar">@config_file_contents</span> = <span class="ruby-identifier">replaced_contents_io</span>.<span class="ruby-identifier">string</span>
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000065" class="method-detail">
        <a name="M000065"></a>

        <div class="method-heading">
          <a href="#M000065" class="method-signature">
          <span class="method-name">save</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
<a href="ConfigFile.html#M000065">save</a> modified content
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000065-source">
<pre>
<span class="ruby-comment cmt"># File lib/svengali/config.rb, line 73</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>
      <span class="ruby-identifier">write_contents_remote</span>(<span class="ruby-ivar">@remote_filepath_str</span>,<span class="ruby-ivar">@config_file_contents</span>)
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>